﻿using UnityEngine;
using System.Collections;
using DG.Tweening;

public class ActorShock : MonoBehaviour {

    /// <summary>
    /// 摇晃力度
    /// </summary>
    Vector3 ShakePower;

    /// <summary>
    /// 动作缓存
    /// </summary>
    Tweener SelfTween;

    //frequency

    public void Play(float duration , Vector3 shakePower)
    {
        _ToZero();
        SelfTween = transform.DOShakePosition(duration, shakePower , 35);
    }

    public void Stop()
    {
        _ToZero();
        SelfTween.Kill();
    }

    public void Destroy()
    {
        _ToZero();
        Destroy(this);
    }

    void _ToZero()
    {
        transform.localPosition = Vector3.zero;
    }
}
